# 求解1-100中能被3整除的所有数字的和
i = 1
sun = 0
while i <= 100:
    if i % 3 == 0:
        sun += i
    i += 1
# print(sun)
# # 2. 求解1-100 能被3和5同时整除的数字的和
# i = 1
# sun = 0
# while i <= 100:
#     if i % 3 == 0 and i % 5 == 0:
#         sun += i
#     i += 1
# print(sun)
# 定义一个文件操作类File，方法有：读取所有内容，读取数据按行返回，写入内容，追加数据。
# File.read(文件名)
# File.write(文件名,’内容’)
# File.readlines(文件名)
# File.append(文件名,’内容’
class File:
    @staticmethod
    def read(filename):
        f = open(f'{filename}', 'r', encoding='utf8')
        content = f.read()
        f.close()
        return content
    @staticmethod
    def write(filename,content):
        f = open(f'{filename}', 'w', encoding='utf8')
        f.write((content))
        f.close()
        print('写入成功')
    @staticmethod
    def readlines(folename):
        f = open(f'{folename}', 'r', encoding='utf8' )
        duqu = f.readline()
        f.close()
        return duqu
    @staticmethod
    def append(filenname,content):
        f = open(fr'{filenname}', 'a+', encoding='utf8')
        f.write(content)
        f.close()
        print('追加成功')


File.write('zhuzhu.txt', 'zhuzhu')
print(File.read('zhuzhu.txt'))
print(File.readlines('zhuzhu.txt'))
File.append('zhuzhu.txt', 'hahahaha')
print(File.readlines('zhuzhu.txt'))






class Flie:
    @staticmethod
    def kan(kan1):
        f = open(f'{kan1}', 'r', encoding = 'utf8')
        leirou = f.read()
        f.close()
        return leirou
    @staticmethod
    def xie(kan1,xie1):
        f = open(f'{kan1}', 'w', encoding='utf8')
        f.write(xie1)
        f.close()
        print('写入成功')
    @staticmethod
    def du1(kan1):
        f = open(f'{kan1}', 'r', encoding='urf8')
        lei = f.readline()
        f.close()
        return lei
    @staticmethod
    def cha(kan1,cha1):
        f = open(f'{kan1}', 'a', encoding='urf8')
        f.write(cha1)
        f.close()
        print('插入成功')
Flie.xie('mimi.py','擦到大大大大')
